<template>
  <a-form
    :model="sysConfig.pageConfig"
    layout="vertical"
    @finish="submit"
    :wrapperCol="{ span: 12 }"
  >
    <a-form-item
      required
      name="pageTitle"
      help="将会修改页面的标题，用户刷新后生效"
      label="页面标题"
    >
      <div>
        <a-input v-model:value="sysConfig.pageConfig.pageTitle" placeholder="请输入标题"></a-input>
      </div>
    </a-form-item>
    <a-form-item name="staticResourceUrl" help="系统图标的外链地址" label="资源地址" required>
      <div>
        <a-input v-model:value="sysConfig.pageConfig.staticResourceUrl"></a-input>
      </div>
    </a-form-item>
    <a-form-item name="version" help="根据这个信息更新页面" label="版本号" required>
      <div>
        <a-input v-model:value="sysConfig.pageConfig.version" placeholder="请输入版本"></a-input>
      </div>
    </a-form-item>

    <a-form-item>
      <a-button size="middle" type="primary" htmlType="submit">保存</a-button>
    </a-form-item>
  </a-form>
</template>

<script setup lang="ts">
import { saveConfig } from '@/api/modules/system/config/utils';
import { SYSTEM_CONFIG } from '@/global/enum/common';
import { Modal } from 'ant-design-vue';
import { sysConfig } from '../data/data';
const loading = ref(false);
const submit = async () => {
  Modal.confirm({
    content: '这些配置将会影响到用户，在校验信息填写正确后再确定',
    title: `警告`,
    centered: true,
    async onOk() {
      loading.value = true;
      await saveConfig(SYSTEM_CONFIG.SYS_SETTINGS, JSON.stringify(sysConfig.value));
      loading.value = false;
    },
  });
};
</script>

<style lang="scss" scoped></style>
